/********************************************************************
FileName    :   Bll_sytz.cs
CreateTime  :   2015-10-15 10:10
BaseClass   :   Bll_sytz
FileType    :   .cs
Author      :  minjie
Description :   Bll_sytzBLL层（简单三层）
*********************************************************************/

using System;
using System.Text;
using System.Collections.Generic;

using System.Data;
using OS.Common;
using OS.DAL;
namespace OS.BLL
{
	/// <summary>
	/// Bll_sytz的摘要说明。
	/// </summary>
public partial class   Bll_sytz 
  	{ 
     		      
  		private readonly Dal_sytz dal=new  Dal_sytz(); 
  		public  Bll_sytz() 
  		{} 
  		 
  		#region  Method 
  		/// <summary> 
  		/// 增加一条数据 
  		/// </summary> 
  		public bool  Add(sytz_Entity model) 
  		{ 
  			return dal.Add(model); 
  		} 
   
  		/// <summary> 
  		/// 增加一条数据 
  		/// </summary> 
  		public  string  AddStr(sytz_Entity model) 
  		{ 
  			return dal.AddStr(model); 
  		} 
   
  		/// <summary> 
  		/// 更新一条数据 
  		/// </summary> 
  		public bool Update(sytz_Entity model) 
  		{ 
  			return dal.Update(model); 
  		} 
   
  		/// <summary> 
  		/// 删除一条数据 
  		/// </summary> 
  		public bool Delete(string  bmh) 
  		{ 
  			 
  			return dal.Delete(bmh); 
  		} 
  		/// <summary> 
  		/// 批量删除一批数据 
  		/// </summary> 
  		public bool DeleteList(string bmhlist ) 
  		{ 
  			return dal.DeleteList(bmhlist ); 
  		} 
  		/// <summary> 
  		/// 得到一个对象实体 
  		/// </summary> 
  		public sytz_Entity GetModel(string  bmh) 
  		{ 
  			 
  			return dal.GetModel(bmh); 
  		} 
   
  		/// <summary> 
  		/// 获得数据列表 
  		/// </summary> 
  		public DataSet GetList(string strWhere) 
  		{ 
  			return dal.GetList(strWhere); 
  		} 
  		/// <summary> 
  		/// 获得前几行数据 
  		/// </summary> 
  		public DataSet GetList(int Top,string strWhere,string filedOrder) 
  		{ 
  			return dal.GetList(Top,strWhere,filedOrder); 
  		} 
  		/// <summary> 
  		/// 获得数据列表 
  		/// </summary> 
  		public List<sytz_Entity> GetModelList(string strWhere) 
  		{ 
  			DataSet ds = dal.GetList(strWhere); 
  			return DataTableToList(ds.Tables[0]); 
  		} 
  		/// <summary> 
  		/// 获得数据列表 
  		/// </summary> 
  		public List<sytz_Entity> GetModelList(string strWhere, string orderby, int startIndex, int endIndex) 
  		{ 
  			DataSet ds = dal.GetListByPage(strWhere, orderby, startIndex, endIndex); 
  			return DataTableToList(ds.Tables[0]); 
  		}
        /// <summary>
        /// 翻页
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public List<sytz_Entity> GetModelList(int pageIndex, int pageSize, string strWhere)
        {
            DataSet ds = dal.GetListByPage(pageIndex, pageSize, strWhere);
            return DataTableToList(ds.Tables[0]);
        }

  		/// <summary> 
  		/// 获得数据列表 
  		/// </summary> 
  		public List<sytz_Entity> DataTableToList(DataTable dt) 
  		{ 
  			List<sytz_Entity> modelList = new List<sytz_Entity>(); 
  		  if (dt!=null ) 
  		  { 
  			int rowsCount = dt.Rows.Count; 
  			if (rowsCount > 0) 
  			{ 
  				sytz_Entity   model; 
  				for (int n = 0; n < rowsCount; n++) 
  				{ 
  					model = new sytz_Entity();					 
  				if(dt.Rows[n]["rq"]!=null&&dt.Rows[n]["rq"].ToString()!="") 
  				{ 
  					model.rq=DateTime.Parse(dt.Rows[n]["rq"].ToString());
                    model.rq2 = model.rq.ToString("yyyy-MM-dd HH:mm:ss");
  				} 
  				model.bmh= dt.Rows[n]["bmh"].ToString(); 
  				model.pzh= dt.Rows[n]["pzh"].ToString(); 
  				model.spbh= dt.Rows[n]["spbh"].ToString(); 
  				if(dt.Rows[n]["sl"]!=null&&dt.Rows[n]["sl"].ToString()!="") 
  				{ 
  					model.sl=decimal.Parse(dt.Rows[n]["sl"].ToString()); 
  				} 
  				if(dt.Rows[n]["dj"]!=null&&dt.Rows[n]["dj"].ToString()!="") 
  				{ 
  					model.dj=decimal.Parse(dt.Rows[n]["dj"].ToString()); 
  				} 
  				model.czy= dt.Rows[n]["czy"].ToString(); 
  				model.mem= dt.Rows[n]["mem"].ToString(); 
  				if(dt.Rows[n]["csbj"]!=null&&dt.Rows[n]["csbj"].ToString()!="") 
  				{ 
  					model.csbj=int.Parse(dt.Rows[n]["csbj"].ToString()); 
  				} 
  				model.dh= dt.Rows[n]["dh"].ToString(); 
  				model.kw= dt.Rows[n]["kw"].ToString(); 
  				if(dt.Rows[n]["kcsl"]!=null&&dt.Rows[n]["kcsl"].ToString()!="") 
  				{ 
  					model.kcsl=decimal.Parse(dt.Rows[n]["kcsl"].ToString()); 
  				} 
  				if(dt.Rows[n]["pdsl"]!=null&&dt.Rows[n]["pdsl"].ToString()!="") 
  				{ 
  					model.pdsl=decimal.Parse(dt.Rows[n]["pdsl"].ToString()); 
  				} 
  				 
  					modelList.Add(model); 
  				} 
  			} 
  		} 
  			return modelList; 
  		} 
   
  		/// <summary> 
  		/// 获得数据列表 
  		/// </summary> 
  		public DataSet GetAllList() 
  		{ 
  			return GetList(""); 
  		} 
   
  		/// <summary> 
  		/// 获取记录总数 
  		/// </summary> 
  		public int GetRecordCount(string strWhere) 
  		{ 
  			return  dal.GetRecordCount(strWhere); 
  		}
        public int Update(List<sytz_Entity> ls)
        {
            return dal.Update(ls);
        }

  #endregion 
      
  	} 
  
}
